package com.tinckay.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.tinckay.entity.po.PumpMonData;
import com.tinckay.service.PumpMonDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.extension.api.ApiController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 * 泵车前端监测数据 前端控制器
 * </p>
 *
 * @author Jean
 * @since 2018-11-13
 */
@Api(tags = "泵车前端监测数据")
@RestController
@RequestMapping("/pumpMonData")
public class PumpMonDataController extends ApiController {

    @Autowired
    private PumpMonDataService pumpMonDataService;

    @GetMapping("/list")
    @ApiOperation("分页查询泵车前端监测数据列表")
    //@RequiresPermissions("pumpMonData:list")
    public R list(@RequestParam(value = "storeCode") String storeCode,
                  @RequestParam(required = false) String startTime,
                  @RequestParam(required = false) String endTime) {
        LambdaQueryWrapper<PumpMonData> wrapper = new QueryWrapper<PumpMonData>()
                .lambda()
                .eq(PumpMonData::getStoreCode, storeCode)
                .ge(StrUtil.isNotBlank(startTime), PumpMonData::getDataTime, startTime)
                .le(StrUtil.isNotBlank(endTime), PumpMonData::getDataTime, endTime);
        List<PumpMonData> result = pumpMonDataService.list(wrapper);
        return success(result);
    }

    @ApiIgnore
    @GetMapping("/info/{pumpMonDataId}")
    @ApiOperation("获取泵车前端监测数据")
    //@RequiresPermissions("pumpMonData:info")
    public R<PumpMonData> info(@PathVariable("pumpMonDataId") long pumpMonDataId) {
        return success(pumpMonDataService.getById(pumpMonDataId));
    }

}

